home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / AppleEvents.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  13.6 KB  |  362 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        AppleEvents.h
  3.  
  4.      Contains:    AppleEvent Package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __APPLEEVENTS__
  18. #define __APPLEEVENTS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __MIXEDMODE__
  24. #include <MixedMode.h>
  25. #endif
  26. #ifndef __NOTIFICATION__
  27. #include <Notification.h>
  28. #endif
  29. #ifndef __EVENTS__
  30. #include <Events.h>
  31. #endif
  32. /*
  33.     Note:    The functions and types for the building and parsing AppleEvent  
  34.             messages has moved to AEDataModel.h
  35. */
  36. #ifndef __AEDATAMODEL__
  37. #include <AEDataModel.h>
  38. #endif
  39.  
  40.  
  41.  
  42. #if PRAGMA_ONCE
  43. #pragma once
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT
  51. #pragma import on
  52. #endif
  53.  
  54. #if PRAGMA_STRUCT_ALIGN
  55.     #pragma options align=mac68k
  56. #elif PRAGMA_STRUCT_PACKPUSH
  57.     #pragma pack(push, 2)
  58. #elif PRAGMA_STRUCT_PACK
  59.     #pragma pack(2)
  60. #endif
  61.  
  62.  
  63. enum {
  64.                                                                 /* Keywords for Apple event parameters */
  65.     keyDirectObject                = FOUR_CHAR_CODE('----'),
  66.     keyErrorNumber                = FOUR_CHAR_CODE('errn'),
  67.     keyErrorString                = FOUR_CHAR_CODE('errs'),
  68.     keyProcessSerialNumber        = FOUR_CHAR_CODE('psn '),        /* Keywords for special handlers */
  69.     keyPreDispatch                = FOUR_CHAR_CODE('phac'),        /* preHandler accessor call */
  70.     keySelectProc                = FOUR_CHAR_CODE('selh'),        /* more selector call */
  71.                                                                 /* Keyword for recording */
  72.     keyAERecorderCount            = FOUR_CHAR_CODE('recr'),        /* available only in vers 1.0.1 and greater */
  73.                                                                 /* Keyword for version information */
  74.     keyAEVersion                = FOUR_CHAR_CODE('vers')        /* available only in vers 1.0.1 and greater */
  75. };
  76.  
  77. /* Event Class */
  78.  
  79. enum {
  80.     kCoreEventClass                = FOUR_CHAR_CODE('aevt')
  81. };
  82.  
  83. /* Event ID’s */
  84.  
  85. enum {
  86.     kAEOpenApplication            = FOUR_CHAR_CODE('oapp'),
  87.     kAEOpenDocuments            = FOUR_CHAR_CODE('odoc'),
  88.     kAEPrintDocuments            = FOUR_CHAR_CODE('pdoc'),
  89.     kAEQuitApplication            = FOUR_CHAR_CODE('quit'),
  90.     kAEAnswer                    = FOUR_CHAR_CODE('ansr'),
  91.     kAEApplicationDied            = FOUR_CHAR_CODE('obit')
  92. };
  93.  
  94. /* Constants for recording */
  95.  
  96. enum {
  97.     kAEStartRecording            = FOUR_CHAR_CODE('reca'),        /* available only in vers 1.0.1 and greater */
  98.     kAEStopRecording            = FOUR_CHAR_CODE('recc'),        /* available only in vers 1.0.1 and greater */
  99.     kAENotifyStartRecording        = FOUR_CHAR_CODE('rec1'),        /* available only in vers 1.0.1 and greater */
  100.     kAENotifyStopRecording        = FOUR_CHAR_CODE('rec0'),        /* available only in vers 1.0.1 and greater */
  101.     kAENotifyRecording            = FOUR_CHAR_CODE('recr')        /* available only in vers 1.0.1 and greater */
  102. };
  103.  
  104.  
  105. /* parameter to AESend */
  106. typedef OptionBits                         AESendOptions;
  107.  
  108. enum {
  109.     kAENeverInteract            = 0x00000010,                    /* server should not interact with user */
  110.     kAECanInteract                = 0x00000020,                    /* server may try to interact with user */
  111.     kAEAlwaysInteract            = 0x00000030,                    /* server should always interact with user where appropriate */
  112.     kAECanSwitchLayer            = 0x00000040,                    /* interaction may switch layer */
  113.     kAEDontRecord                = 0x00001000,                    /* don't record this event - available only in vers 1.0.1 and greater */
  114.     kAEDontExecute                = 0x00002000,                    /* don't send the event for recording - available only in vers 1.0.1 and greater */
  115.     kAEProcessNonReplyEvents    = 0x00008000                    /* allow processing of non-reply events while awaiting synchronous AppleEvent reply */
  116. };
  117.  
  118. typedef SInt32                             AESendMode;
  119.  
  120. enum {
  121.     kAENoReply                    = 0x00000001,                    /* sender doesn't want a reply to event */
  122.     kAEQueueReply                = 0x00000002,                    /* sender wants a reply but won't wait */
  123.     kAEWaitReply                = 0x00000003,                    /* sender wants a reply and will wait */
  124.     kAEDontReconnect            = 0x00000080,                    /* don't reconnect if there is a sessClosedErr from PPCToolbox */
  125.     kAEWantReceipt                = 0x00000200                    /* (nReturnReceipt) sender wants a receipt of message */
  126. };
  127.  
  128.  
  129. /* Constants for timeout durations */
  130.  
  131. enum {
  132.     kAEDefaultTimeout            = -1,                            /* timeout value determined by AEM */
  133.     kNoTimeOut                    = -2                            /* wait until reply comes back, however long it takes */
  134. };
  135.  
  136.  
  137. /* priority param of AESend */
  138. typedef SInt16                             AESendPriority;
  139.  
  140. enum {
  141.     kAENormalPriority            = 0x00000000,                    /* post message at the end of the event queue */
  142.     kAEHighPriority                = 0x00000001                    /* post message at the front of the event queue (same as nAttnMsg) */
  143. };
  144.  
  145.  
  146. typedef SInt8                             AEEventSource;
  147.  
  148. enum {
  149.     kAEUnknownSource            = 0,
  150.     kAEDirectCall                = 1,
  151.     kAESameProcess                = 2,
  152.     kAELocalProcess                = 3,
  153.     kAERemoteProcess            = 4
  154. };
  155.  
  156.  
  157.  
  158. typedef CALLBACK_API( OSErr , AEEventHandlerProcPtr )(const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefcon);
  159. typedef CALLBACK_API( Boolean , AEIdleProcPtr )(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn);
  160. typedef CALLBACK_API( Boolean , AEFilterProcPtr )(EventRecord *theEvent, long returnID, long transactionID, const AEAddressDesc *sender);
  161. typedef STACK_UPP_TYPE(AEEventHandlerProcPtr)                     AEEventHandlerUPP;
  162. typedef STACK_UPP_TYPE(AEIdleProcPtr)                             AEIdleUPP;
  163. typedef STACK_UPP_TYPE(AEFilterProcPtr)                         AEFilterUPP;
  164. enum { uppAEEventHandlerProcInfo = 0x00000FE0 };                 /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  165. enum { uppAEIdleProcInfo = 0x00000FD0 };                         /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes) */
  166. enum { uppAEFilterProcInfo = 0x00003FD0 };                         /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  167. #define NewAEEventHandlerProc(userRoutine)                         (AEEventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEEventHandlerProcInfo, GetCurrentArchitecture())
  168. #define NewAEIdleProc(userRoutine)                                 (AEIdleUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture())
  169. #define NewAEFilterProc(userRoutine)                             (AEFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEFilterProcInfo, GetCurrentArchitecture())
  170. #define CallAEEventHandlerProc(userRoutine, theAppleEvent, reply, handlerRefcon)  CALL_THREE_PARAMETER_UPP((userRoutine), uppAEEventHandlerProcInfo, (theAppleEvent), (reply), (handlerRefcon))
  171. #define CallAEIdleProc(userRoutine, theEvent, sleepTime, mouseRgn)  CALL_THREE_PARAMETER_UPP((userRoutine), uppAEIdleProcInfo, (theEvent), (sleepTime), (mouseRgn))
  172. #define CallAEFilterProc(userRoutine, theEvent, returnID, transactionID, sender)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppAEFilterProcInfo, (theEvent), (returnID), (transactionID), (sender))
  173.  
  174. /**************************************************************************
  175.   The next couple of calls are basic routines used to create, send,
  176.   and process AppleEvents. 
  177. **************************************************************************/
  178. EXTERN_API( OSErr )
  179. AESend                            (const AppleEvent *        theAppleEvent,
  180.                                  AppleEvent *            reply,
  181.                                  AESendMode             sendMode,
  182.                                  AESendPriority         sendPriority,
  183.                                  long                     timeOutInTicks,
  184.                                  AEIdleUPP                 idleProc,
  185.                                  AEFilterUPP             filterProc)                            THREEWORDINLINE(0x303C, 0x0D17, 0xA816);
  186.  
  187. EXTERN_API( OSErr )
  188. AEProcessAppleEvent                (const EventRecord *    theEventRecord)                        THREEWORDINLINE(0x303C, 0x021B, 0xA816);
  189.  
  190.  
  191. /* 
  192.  Note: during event processing, an event handler may realize that it is likely
  193.  to exceed the client's timeout limit. Passing the reply to this
  194.  routine causes a wait event to be generated that asks the client
  195.  for more time. 
  196. */
  197. EXTERN_API( OSErr )
  198. AEResetTimer                    (const AppleEvent *        reply)                                THREEWORDINLINE(0x303C, 0x0219, 0xA816);
  199.  
  200.  
  201. /**************************************************************************
  202.   The following three calls are used to allow applications to behave
  203.   courteously when a user interaction such as a dialog box is needed. 
  204. **************************************************************************/
  205.  
  206. typedef SInt8                             AEInteractAllowed;
  207.  
  208. enum {
  209.     kAEInteractWithSelf            = 0,
  210.     kAEInteractWithLocal        = 1,
  211.     kAEInteractWithAll            = 2
  212. };
  213.  
  214. EXTERN_API( OSErr )
  215. AEGetInteractionAllowed            (AEInteractAllowed *    level)                                THREEWORDINLINE(0x303C, 0x021D, 0xA816);
  216.  
  217. EXTERN_API( OSErr )
  218. AESetInteractionAllowed            (AEInteractAllowed         level)                                THREEWORDINLINE(0x303C, 0x011E, 0xA816);
  219.  
  220. EXTERN_API( OSErr )
  221. AEInteractWithUser                (long                     timeOutInTicks,
  222.                                  NMRecPtr                 nmReqPtr,
  223.                                  AEIdleUPP                 idleProc)                            THREEWORDINLINE(0x303C, 0x061C, 0xA816);
  224.  
  225.  
  226. /**************************************************************************
  227.   These calls are used to set up and modify the event dispatch table.
  228. **************************************************************************/
  229. EXTERN_API( OSErr )
  230. AEInstallEventHandler            (AEEventClass             theAEEventClass,
  231.                                  AEEventID                 theAEEventID,
  232.                                  AEEventHandlerUPP         handler,
  233.                                  long                     handlerRefcon,
  234.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x091F, 0xA816);
  235.  
  236. EXTERN_API( OSErr )
  237. AERemoveEventHandler            (AEEventClass             theAEEventClass,
  238.                                  AEEventID                 theAEEventID,
  239.                                  AEEventHandlerUPP         handler,
  240.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0720, 0xA816);
  241.  
  242. EXTERN_API( OSErr )
  243. AEGetEventHandler                (AEEventClass             theAEEventClass,
  244.                                  AEEventID                 theAEEventID,
  245.                                  AEEventHandlerUPP *    handler,
  246.                                  long *                    handlerRefcon,
  247.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0921, 0xA816);
  248.  
  249.  
  250. /**************************************************************************
  251.  The following four calls are available for applications which need more
  252.  sophisticated control over when and how events are processed. Applications
  253.  which implement multi-session servers or which implement their own
  254.  internal event queueing will probably be the major clients of these
  255.  routines. They can be called from within a handler to prevent the AEM from
  256.  disposing of the AppleEvent when the handler returns. They can be used to
  257.  asynchronously process the event (as MacApp does).
  258. **************************************************************************/
  259. EXTERN_API( OSErr )
  260. AESuspendTheCurrentEvent        (const AppleEvent *        theAppleEvent)                        THREEWORDINLINE(0x303C, 0x022B, 0xA816);
  261.  
  262. /* 
  263.  Note: The following routine tells the AppleEvent manager that processing
  264.  is either about to resume or has been completed on a previously suspended
  265.  event. The procPtr passed in as the dispatcher parameter will be called to
  266.  attempt to redispatch the event. Several constants for the dispatcher
  267.  parameter allow special behavior. They are:
  268.       - kAEUseStandardDispatch means redispatch as if the event was just
  269.       received, using the standard AppleEvent dispatch mechanism.
  270.       - kAENoDispatch means ignore the parameter.
  271.          Use this in the case where the event has been handled and no
  272.       redispatch is needed.
  273.       - non nil means call the routine which the dispatcher points to.
  274. */
  275. /* Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch */
  276.  
  277. enum {
  278.     kAEDoNotIgnoreHandler        = 0x00000000,
  279.     kAEIgnoreAppPhacHandler        = 0x00000001,                    /* available only in vers 1.0.1 and greater */
  280.     kAEIgnoreAppEventHandler    = 0x00000002,                    /* available only in vers 1.0.1 and greater */
  281.     kAEIgnoreSysPhacHandler        = 0x00000004,                    /* available only in vers 1.0.1 and greater */
  282.     kAEIgnoreSysEventHandler    = 0x00000008,                    /* available only in vers 1.0.1 and greater */
  283.     kAEIngoreBuiltInEventHandler = 0x00000010,                    /* available only in vers 1.0.1 and greater */
  284.     kAEDontDisposeOnResume        = (long)0x80000000                /* available only in vers 1.0.1 and greater */
  285. };
  286.  
  287. /* Constants for AEResumeTheCurrentEvent */
  288.  
  289. enum {
  290.     kAENoDispatch                = 0,                            /* dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch */
  291.     kAEUseStandardDispatch        = (long)0xFFFFFFFF                /* table, or one of these two constants */
  292. };
  293.  
  294. EXTERN_API( OSErr )
  295. AEResumeTheCurrentEvent            (const AppleEvent *        theAppleEvent,
  296.                                  const AppleEvent *        reply,
  297.                                  AEEventHandlerUPP         dispatcher,
  298.                                  long                     handlerRefcon)                        THREEWORDINLINE(0x303C, 0x0818, 0xA816);
  299.  
  300. EXTERN_API( OSErr )
  301. AEGetTheCurrentEvent            (AppleEvent *            theAppleEvent)                        THREEWORDINLINE(0x303C, 0x021A, 0xA816);
  302.  
  303. EXTERN_API( OSErr )
  304. AESetTheCurrentEvent            (const AppleEvent *        theAppleEvent)                        THREEWORDINLINE(0x303C, 0x022C, 0xA816);
  305.  
  306.  
  307. /**************************************************************************
  308.   These calls are used to set up and modify special hooks into the
  309.   AppleEvent manager.
  310. **************************************************************************/
  311. EXTERN_API( OSErr )
  312. AEInstallSpecialHandler            (AEKeyword                 functionClass,
  313.                                  UniversalProcPtr         handler,
  314.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0500, 0xA816);
  315.  
  316. EXTERN_API( OSErr )
  317. AERemoveSpecialHandler            (AEKeyword                 functionClass,
  318.                                  UniversalProcPtr         handler,
  319.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0501, 0xA816);
  320.  
  321. EXTERN_API( OSErr )
  322. AEGetSpecialHandler                (AEKeyword                 functionClass,
  323.                                  UniversalProcPtr *        handler,
  324.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x052D, 0xA816);
  325.  
  326.  
  327. /**************************************************************************
  328.   This call was added in version 1.0.1. If called with the keyword
  329.   keyAERecorderCount ('recr'), the number of recorders that are
  330.   currently active is returned in 'result'
  331.   (available only in vers 1.0.1 and greater).
  332. **************************************************************************/
  333. EXTERN_API( OSErr )
  334. AEManagerInfo                    (AEKeyword                 keyWord,
  335.                                  long *                    result)                                THREEWORDINLINE(0x303C, 0x0441, 0xA816);
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342. #if PRAGMA_STRUCT_ALIGN
  343.     #pragma options align=reset
  344. #elif PRAGMA_STRUCT_PACKPUSH
  345.     #pragma pack(pop)
  346. #elif PRAGMA_STRUCT_PACK
  347.     #pragma pack()
  348. #endif
  349.  
  350. #ifdef PRAGMA_IMPORT_OFF
  351. #pragma import off
  352. #elif PRAGMA_IMPORT
  353. #pragma import reset
  354. #endif
  355.  
  356. #ifdef __cplusplus
  357. }
  358. #endif
  359.  
  360. #endif /* __APPLEEVENTS__ */
  361.  
  362.